{extend name="main/index" /}
{block name="main"}
<!-- Start right content -->
<div class="content-page">
    <!-- ============================================================== -->
    <!-- Start Content here -->
    <!-- ============================================================== -->
    <div class="content">
        <!-- Page Heading Start -->
        <div class="page-heading">
            <h1><i class='fa fa-table'></i> 用户管理</h1>
            <h3>用户列表</h3></div>
        <!-- Page Heading End-->                <!-- Your awesome content goes here -->
        <div class="row">

            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>用户列表</strong> Table</h2>
                        <div class="additional-btn">
                            <a href="#" class="hidden reload"><i class="icon-ccw-1"></i></a>
                            <a href="#" class="widget-toggle"><i class="icon-down-open-2"></i></a>
                            <a href="#" class="widget-close"><i class="icon-cancel-3"></i></a>
                        </div>
                    </div>
                    <div class="widget-content">
                        <div class="table-responsive">
                            <table data-sortable class="table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th style="width: 30px" data-sortable="false">
                                        <input type="checkbox" class="rows-check"></th>
                                    <th>用户名</th>
                                    <th>手机号</th>
                                    <th>状态</th>
                                    <th>个人信息</th>
                                    <th data-sortable="false">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                {volist name="list" id="v"}
                                <tr class="aaa">
                                    <td>{$v['auid']}</td>
                                    <td><input type="checkbox" class="rows-check"></td>
                                    <td><strong>{$v['username']}</strong></td>
                                    <td>{$v['tel']}</td>
                                    <td> {$v['status'] == 0? '激活' : '禁用'}</td>

                                    <td>
                                        <a href="{:url('admin/Auser/readch', ['id'=>$v['auid']])}" data-toggle="tooltip" title="" class="btn btn-default">查看详情</a>
                                    </td>

                                    <td>
                                        <!-- <div class="btn-group btn-group-xs"> -->

                                        <button data-id="{$v['auid']}" class="btn btn-default del-btn">删除</button>
                                        <a href="{:url('admin/Auser/edit', ['id'=>$v['auid']])}" data-toggle="tooltip" title="" class="btn btn-default">编辑</a>
                                        <a href="{:url('admin/Auser/roleList', ['id'=>$v['auid']])}" data-toggle="tooltip" title="" class="btn btn-default">权限分配</a>
                                        <!-- </div> -->
                                    </td>

                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                    </div>
                    <div class="modal-body myBody">

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Save changes</button>
                    </div>
                </div>
            </div>
        </div>




    </div>
    <!-- ============================================================== -->
    <!-- End content here -->
    <!-- ============================================================== -->

</div>
<!-- End right content -->
{js href="/static/index/js/jquery.min.js"}


<script>

    // $('.sta-btn').click(function () {
    //     // console.log(1);
    //     var ac_id=$(this).attr('data-id');
    //     console.log(ac_id);
    //
    //     if(confirm('你确定要禁用吗')){
    //         var obj=$(this).parent('.aaa');
    //         console.log(obj);
    //         delAjax(ac_id,obj);
    //     }
    //
    // });

    $('.del-btn').click(function () {
        var ac_id=$(this).attr('data-id');
        if(confirm('你确定要删除吗')){
            var obj=$(this).parent('.aaa');
            console.log(obj);
            delAjax(ac_id,obj);
        }

    });

    function delAjax(id,obj) {
        $.ajax({
            type:'delete',
            url:'/roles/'+id,
            dataType:'json',
            success:function (data){
                if(data.status){
                    alert(data.info);
                    obj.remove();

                }else{
                    alert(data.info);
                }
            },
            error: function (err) {
                alert('删除失败');

            }


        });

    }



</script>


{/block}